import axios from 'axios'


export function daochupost(url,data) {
  return new Promise((resolve, reject) => {
      axios.post(url, data)
          .then(response => {
              if(response.data.msg.code == 0){
                location.href = location.origin + response.data.data.path
              }else{
                this.$message.error(response.data.msg.info);
              }
          })
  })
}


import XLSX from 'xlsx';
import { read,utils } from 'xlsx'

export function jiexiexcle(file){
  let files = file.file
  return new Promise((res, rej) => {
    var that = this;
    if (files.length <= 0) {
      return;
    }
    if (!/\.(xls|xlsx)$/.test(files.name.toLowerCase())) {
      ELEMENT.Message.error('上传格式不正确，请上传xls或者xlsx格式')
      return;
    }
    const fileReader = new FileReader();
    fileReader.onload = (ev) => {
      try {
        const data = ev.target.result;
        const workbook = read(data, {
          type: 'binary'
        });
        // 取第一张表
        const wsname = workbook.SheetNames[0];
        // 生成json表格内容
        const ws = utils.sheet_to_json(workbook.Sheets[wsname]);
        // 后续为自己对ws数据的处理
        res(ws)
      } catch (e) {
        return false;
        rej(e)
      }
    };
    fileReader.readAsBinaryString(files);
  })
}
